#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
struct node{
    int lft,rht;
    bool bl,br;
}ti[N];
int T,n,m,L,V,p[N],ans,ans1;
bool vis[N],vis2[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        vector<int> vt[N];
        memset(vis2,0,sizeof(vis2));
        memset(vis,0,sizeof(vis));
        ans1=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            int st,v,a;
            cin>>st>>v>>a;
            if(v>V && a>=0)
              ti[i].lft=st,ti[i].rht=L,ti[i].bl=1,ti[i].br=1;
            else if(v==V && a>0)
                ti[i].lft=st,ti[i].rht=L,ti[i].bl=0,ti[i].br=1;
            else if(v<=V && a<=0)
                ti[i].lft=-1,ti[i].rht=-1;
            else{
                double t=(V*V-v*v)*1.0/2/a;
                if(v>V){
                    ti[i].lft=st,ti[i].rht=st+ceil(t);
                    ti[i].bl=1,ti[i].br=0;
                }
                else{
                    ti[i].lft=st+ceil(t),ti[i].rht=n;
                    ti[i].bl=0,ti[i].br=1;
                    if(int(t)!=t) ti[i].bl=1;
                }
            }
        }
        //for(int i=1;i<=n;i++)
            //cout<<ti[i].lft<<' '<<ti[i].rht<<' '<<ti[i].bl<<' '<<ti[i].br<<endl;
        for(int i=1;i<=m;i++){
            cin>>p[i];
            for(int j=1;j<=n;j++)
            {
                int sum=0;
                if(ti[j].bl && p[i]>=ti[j].lft) sum++;
                if(!ti[j].bl && p[i]>ti[j].lft) sum++;
                if(ti[j].br && p[i]<=ti[j].rht) sum++;
                if(!ti[j].br && p[i]<ti[j].rht) sum++;
                if(sum==2){
                    vt[i].push_back(j);
                    if(!vis[j]){
                        vis[j]=1;
                        ans1++;
                    }

                }
            }

        }
        ans=INT_MAX;
        cout<<ans1<<' '<<ans1<<endl;
    }
    return 0;
}
